#include <stdio.h>
#include<stdlib.h>

typedef struct Tree
{
    char val;
    struct Tree* left;
    struct Tree* right;
}BTNode;

BTNode* BuyNode(char x)
{
    BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
    newnode->val = x;
    newnode->left = NULL;
    newnode->right = NULL;
    return newnode;
}


BTNode* TreeCreate(char* a, int* i)
{
    if (a[*i] == '#')
    {
        *i = *i + 1;
        return NULL;
    }
    BTNode* root = BuyNode(a[*i]);
    *i = *i + 1;
    root->left = TreeCreate(a, i);
    root->right = TreeCreate(a, i);
    return root;
}

void inorder(BTNode* root)
{
    if (root == NULL)
        return;
    inorder(root->left);
    printf("%c ", root->val);
    inorder(root->right);
}


int main()
{
    char a[100];
    scanf("%s", a);
    int i = 0;
    BTNode* root = TreeCreate(a, &i);
    inorder(root);
    return 0;
}